Skip to content

Conversation

igalshilman
Copy link
Contributor

@igalshilman igalshilman commented Mar 21, 2025

with that we can write code like that:

 match await select(result=ctx.promise("verify.payment"), timeout=ctx.sleep(TIMEOUT)):
        case ['result', "approved"]:
            ctx.set("status", "payment approved")
            return { "success" : True }
        case ['result', "declined"]:
            ctx.set("status", "payment declined")
            raise TerminalError(message="Payment declined", status_code=401)
        case ['timeout', _]:
            ctx.set("status", "payment verification timed out")
            raise TerminalError(message="Payment verification timed out", status_code=410)

@igalshilman igalshilman force-pushed the add_select branch 3 times, most recently from 2b399f6 to f3ed5b7 Compare March 21, 2025 19:48
@igalshilman igalshilman merged commit a54ba99 into restatedev:main Mar 21, 2025
4 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Mar 21, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant